# 魔术方法——内置的类方法，具有特殊功能
# 使用构造方法向成员变量赋值


class Student:
    def __init__(self,name,age):
        self.name = name
        self.age = age

    # __str__ 魔术方法—— 自定义输出字符串格式
    def __str__(self):
        return f"Student类对象,name:{self.name},age:{self.age}"

    # __lt__ 魔术方法—— " < " 比较
    def __lt__(self, other):
        return self.age < other.age

    # __eq__ 魔术方法—— " == "
    def __eq__(self, other):
        return self.age == other.age


stu_1 = Student("w",19)
stu_2 = Student("s",21)
print(stu_1 < stu_2)
print(stu_1 > stu_2)
print(stu_1 == stu_2)

